package com.jml.spring.aop注解事务.service.impl;


import com.jml.spring.aop注解事务.annotation.ExtTransational;
import com.jml.spring.aop注解事务.dao.UserDao;
import com.jml.spring.aop注解事务.service.LogService;
import com.jml.spring.aop注解事务.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//user 服务层
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao userDao;
	@Autowired
	private LogService logService;

	//声名式事务
	@ExtTransational
	public void add() {
		int i=10;
		userDao.add("jmll",i);
		int j=1/0;
		System.out.println("--#########往数据库添加数据...");
		userDao.add("jmll",i+1);
	}

	@Transactional
	public void add7() {
		logService.addLog();
		int i=10;
		userDao.add("jmll",i);
		i=1/0;
		System.out.println("--#########往数据库添加数据...");
		userDao.add("jmll",i+1);
	}

}
